<#include "layout/template.ftl"/>

<@htmlHead title="企业列表">
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${resources}/assets/css/jquery-ui.css" />
		<link rel="stylesheet" href="${resources}/assets/css/datepicker.css" />
		<link rel="stylesheet" href="${resources}/assets/css/ui.jqgrid.css" />
		<link rel="stylesheet" href="${resources}/plugins/jqgrid/4.6/jqgrid.extend.css" />
</@htmlHead>


 
<@htmlBody 'system' 'corpManage'>

	<!-- breadcrumbs begin -->
	<#include "layout/breadcrumbs.ftl">
	<@breadcrumbs '企业管理' '企业列表'></@breadcrumbs>
	<!-- breadcrumbs start -->

	<!-- page-content begin -->
	<div class="page-content">
			
			
			<!-- page-header begin -->
			<div class="page-header">
				<div style="margin-top:20px;padding:10px 0px 0px 0px;border-top:1px solid #307ecc">
					<div style="float:right">
						<button id="find_btn"  class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-search"></i>查 询
						</button>
				    </div>
				    
				    <div id="query" class="query-view" style="">
						<ul class="list-inline">
							<li>	
					        	<label>名称:</label><input type="text" class="input" id="name" name="name" data-op="cn" /> 
							</li>
							
						</ul>
					</div>
				</div>
				
			</div>
			<!-- page-header end -->
			
			<!-- form begin -->
			<div class="row">	
				<div class="col-md-12">
					<!-- jqGrid begin -->
				  	<table id="grid-table"></table>
			 		<div id="grid-pager"></div>
			 		<!-- jqGrid end -->
	
				</div>
			</div>	
			<!-- form end -->
	</div>		
	<!-- page-content end -->	


</@htmlBody>



<@htmlBodyScript>
		<script src="${resources}/assets/js/date-time/bootstrap-datepicker.js"></script>
		<script src="${resources}/assets/js/jqGrid/jquery.jqGrid.src.js"></script>
		<script src="${resources}/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>

		<script>
			var $path ='${path}';
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";
			
			$(function(){

				//分页插件开始
				$("#grid-table").jqGrid({
					url: '${path}/manage/system/corp/list',
				 	mtype : "post", 
					datatype: "json",
					//prmNames : {search : "search"},  
					colNames:[ 'ID','公司名称','注册日期','到期日期','分享标题','分享链接','状态','操作'],
				 	colModel: [
						{name:'id', width:60},
						{name:'name', width:100},
						{
							name:'starttime',
							width:100,
							formatter:	function formatDatetime(cellValue, options, rowObject) {
								var output = moment(cellValue).format('YYYY-MM-DD');
								return output;
							}
						},
						{
							name:'overtime',
							width:100,
							formatter:function formatDatetime(cellValue, options, rowObject) {
								var day = moment(cellValue).diff(moment(), 'days');   
								var output = moment(cellValue).format('YYYY-MM-DD');
								if( day<=15 && day>=1){
									return "<span style='color:red'>"+output+", 剩余:"+day+"天</span>";
								}
								if( day==0){
									var diff = moment(cellValue).diff(moment(), 'days',true); 
									if(diff<0){
										return "<span style='color:green'>"+output+", 已过期</span>";
									}else{
										return "<span style='color:blue'>"+output+", 今天到期</span>";
									}
								}
								if(day<0){
									return "<span style='color:green'>"+output+", 已过期</span>";
								}
								return output;
							}
						},
						{name:'title', width:100},
						{name:'shareurl', width:100},
						{
							name:'status',
							width:50,
							formatter:function(cellValue, options, rowObject) {
								var option = '<div class="ui-status">';
								if(cellValue==1){
									option+= "<span class='label label-sm label-success'>正常</span>";
								}else if(cellValue==2){
									option+= "<span class='label label-sm label-danger'>停用</span>";
								}
								option = option +'</div>';      
			               		return option;  
			        		}
						},
						{
							name:'id', 
							width:150,
							formatter:function(cellvalue, options, rawObject) {
					    		var option = '<div class="ui-op">';
					    		option = option +'<a href="${path}/manage/system/corp/update/'+cellvalue+'">编辑'; 
				                option = option +'</a>';
			                   	if(rawObject.status!=2){ 
					                option = option +'<a href="${path}/manage/system/corp/disable/'+cellvalue+'"  onclick=\'return confirm("是否停用?");\'>停用';
				                	option = option +'</a>';  
			                	}
			                	if(rawObject.status!=1){ 
					                option = option +'<a href="${path}/manage/system/corp/enable/'+cellvalue+'"  onclick=\'return confirm("是否启用?");\'>启用';
				                	option = option +'</a>';  
			                	}
			                	option = option +'<a href="${path}/manage/platform/sldConfig/saveOrUpdate?corpid='+cellvalue+'"  >域名配置';
				                option = option +'</a>';
					    		option = option +'<a href="${path}/manage/system/corp/delete/'+cellvalue+'"  onclick=\'return confirm("是否删除?");\'>删除';
				                option = option +'</a>';
				                option = option +'</div>';      
			               		return option;  
							}
						}
					],
					viewrecords: true, 							// 在toolbar显示的当前页数,步长,总数
					autowidth: true,  
              		shrinkToFit: true,  	
					height: "450",
					rowNum: 10,
					rowList:[10,50,100],
					sortname: 'overtime',
					sortorder: 'asc',
					pager: "#grid-pager",
					caption: "列表",
					loadComplete : function() {
						var table = this;
						setTimeout(function(){
							styleCheckbox(table);
							updateActionIcons(table);
							updatePagerIcons(table);
							enableTooltips(table);
						}, 0);
					}
					
				});
						//分页插件结束
				
				//------------------------------- 自定义查询开始 -------------------------------
				//自定义查询开始
				$("#find_btn").click(function(){ 
					searchData('${path}/manage/system/corp/list');
			    }); 
				//自定义查询结束
				
			})
		</script>	
	    <script src="${resources}/assets/js/jqGrid/jquery.jqGrid.Extract.js"></script>
	    

</@htmlBodyScript>